package com.zero2oneblog.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * <p>
 * 
 * </p>
 *
 * @author liangjiu
 * @since 2024-01-08
 */
@TableName("tb_user_role")
@ApiModel(value = "UserRole对象", description = "")
public class UserRole implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    private String username;

    private String role;

    private UserInfo userInfo;
    private Role role_entity; //这里的role_entity是实体。这里的java代码里的表entity可以跟数据库表的记录不一样吗

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    private String description; //对应Role表

//    public UserRole(UserInfo userinfo, Role role) {
//        this.userInfo  = userinfo;
//        this.role_entity = role;
////        this.username = userinfo.getUsername();
////        this.role = role.getRole(); //之前跟原代码有点不一样
//    }

//    public UserRole(UserInfo userinfo, Role role) { //Resolved [org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Error instantiating class com.zero2oneblog.entity.UserRole with invalid types (UserInfo,Role) or values (1,liangjiu). Cause: java.lang.IllegalArgumentException: argument type mismatch]
//        this.id = id;
//        this.username = userinfo.getUsername();
//        this.role = role.getRole(); //之前跟原代码有点不一样
//    public UserRole(Integer id,String username,UserInfo userinfo, Role role) {
    public UserRole(Integer id,String username,String role,String description) {
        this.id = getId();
        this.username = getUsername();
        this.role = role;
        this.description = description;
    }

    public UserRole(UserInfo userInfo,Role role) {
//        this.id = getId();
        this.username = userInfo.getUsername();
        this.role = role.getRole();
//        this.description = role.getDescription();
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    @Override
    public String toString() {
        return "UserRole{" +
            "id = " + id +
            ", username = " + username +
            ", role = " + role +
        "}";
    }
}
